package cn.itcast.scala.course03

/**
  * 条件表达式
  * create by zhangtian on 2018/12/29
  */
object ScalaCondition {
  def main(args: Array[String]): Unit = {
    // if(logic_exp) valA else valB    if表达式的逻辑
    if(true) 1 else 2
    if (false) 3 else 4

    val a = 1
    if (a != 1) "not one" // 这里因为没有else，则返回结果为空，即 res3:Any=()
    if (a != 1) "not one" else a

    val reslt_try = try {
      Integer.parseInt("dogs")
    }catch{
      case _ => 0
    }finally {
      println("always be printed !!!")
    }

    println("result_try:" +reslt_try)

    val code = 1
    var result_match = code match {
      case 1 => "one"
      case 2 => "two"
      case _ => "other"
    }

    println(result_match)
  }
}
